#!/usr/bin/env python3
# -*- coding:utf-8 -*-

import zmail
from config.conf import cm


def send_report():

    with open(cm.REPORT_PATH,'r',encoding="utf-8") as f:
        content_html = f.read()

    try:
        mail = {
            'from': 'yunkunzentao@163.com',
            'subject': '界面自动化测试报告',
            'content_html': content_html,
            'attachments': [cm.REPORT_PATH, ]
        }
        print("REPORT_PATH",cm.REPORT_PATH)
        server = zmail.server(*cm.EMAIL_INFO.values())
        server.send_mail(cm.ADDRESSEE, mail)
    except Exception as e:
        print("Error: 无法发送邮件，{}！", format(e))
    else:
        print("测试邮件发送成功！")



if __name__ == "__main__":
    '''请先在config/conf.py文件设置QQ邮箱的账号和密码'''
    send_report()